class Solution {
    public int thirdMax(int[] nums) {
       long a = Long.MIN_VALUE, b = Long.MIN_VALUE, c = Long.MIN_VALUE ;
       for(int num : nums) {
           if(num > a) {
               c = b; b = a; a = num;
           } else if( num > b && num < a) {
               c = b ; b = num;
           } else if(num > c && num < b) { // 多个判断防重
               c = num;
           }
       }
        return c == Long.MIN_VALUE ? (int)a : (int)c;
    }
}